package com.kongjs.application.controller;

import com.kongjs.application.tenant.TenantRoleHierarchyInitializer;
import com.kongjs.common.rest.annotation.Rest;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Rest
@RestController
@RequestMapping("/role/hierarchy")
public class RoleHierarchyController {

    @Resource
    private TenantRoleHierarchyInitializer tenantRoleHierarchyInitializer;

    @GetMapping("/init")
    public void init() {
        tenantRoleHierarchyInitializer.initRoleHierarchy();
    }

    @GetMapping("/init/{id}")
    public void initId(@PathVariable String tenantId) {
        tenantRoleHierarchyInitializer.initRoleHierarchy(tenantId);
    }

    @GetMapping("/init/all")
    public void initAll() {
        tenantRoleHierarchyInitializer.initAllRoleHierarchy();
    }
}
